﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using S9Engine;

public partial class Category : Parser
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            _parser.SetCurrentDir("~/tpl");
            _parser.SetLanguageFile("~/templates/language.txt", _currentLanguage);
            
            Session["CurrentPage"] = "Category.aspx";
            string type = GetRequest("type");
            
            if (type == "news")
            {
                LoadFile("news_list.html", false);
                _parser.Assign("currentCategoryID", _cid.ToString());
                LoadAllNewsByCategoryID(_cid, "NewsList", false, 0);
            }
            else
            {
                LoadFile("product_list.html", false);
                _parser.Assign("currentCategoryID", _cid.ToString());
                LoadAllProduct("Main", "ProductList", _cid);
            }
            _parser.Assign("language" + Session["Language"].ToString().ToLower(), "class=\"current\"");
            LoadBreadCrumb(_cid, "BreadCrumb");
            _parser.Assign("currentCategoryID", Request["cid"].ToString());
        }
        catch (Exception ex)
        {
            WriteError(ex);
        }
        finally
        {
            _parser.Parse("Main");
            _parser.Out("Main");
        }
    }
}